
ALTER    procedure sp_change_taxes_proc


@state varchar(50),
@old_state varchar(50),
@tax float,
@old_tax float,
@type varchar(10),
@error_code varchar(100) OUTPUT

as

Declare @count int
BEGIN
	if ( @type = 'new')
		Begin
			insert into sales_tax_table values ( @state, @tax ) 
			SET @error_code = 'SUCCESS'			
		End		
	else		
		Begin
			select @count = count(*) from sales_order where so_sales_tax_type = @old_state 
			if ( @count = 0 or @state = @old_state)
				Begin
					if ( @state = '' and @tax = '0.0' )
						Begin
							print 'a'
							delete sales_tax_table where State = @old_state 
							SET @error_code = 'SUCCESS'			
						End
					else
						Begin
							update sales_tax_table set state = @state, tax = @tax where state = @old_state
							SET @error_code = 'SUCCESS'						
						End
				End				
			ELSE 
				Begin
					set @error_code = 'FAIL'
				End
		End
select @error_code
return


END
